<?php
$this->pageTitle=Yii::app()->name . ' - ' . $model->first_name . ' ' . $model->last_name;
?>
<div class="main-content">
	<h1>
	<?php echo $model->first_name . ' ' . $model->last_name; ?>
	</h1>

	<?php
    $arrDetails = array(
        'data'=>$model,
        'attributes'=>array(
        //'id',
            'first_name',
            'last_name',
        //'picture_id',
            array(
                'label'=>'Picture',
                'type'=>'image',
                'value'=>Yii::app()->baseURL . '/user_images/' . $pnmPictureModel->thumbnail_filename,
            ),
            'phone_number',
            'email',
            'major',
            'dorm',
            array(
    			'label'=>'Introductions',
    			'type'=>'raw',
    			'value'=>$numIntroductions.' members have met this PNM '.$introButton,
			),
            array(
				'label'=>'Average Rating',
				'value'=>$averageRating.' ('.$numRatings.' Ratings)',
			    //Display who rated what
	        ),
	        array(
				'label'=>'Choose a Rating',
				'type'=>'raw',
				'value'=>$dropdown,
	        ),
        ),
    );
    
	if (!is_null($ratingsModel)) {
	    $newArray = array('label'=>'Your Rating', 'value'=>$ratingsModel->rating,);
	} else {
	    $newArray = array('label'=>'Your Rating','value'=>'Not Rated');
	}
	array_push($arrDetails['attributes'], $newArray);
	    
    $newArray = array('label'=>'Events Attended', 'type'=>'raw', 'value'=>'(Count: ' . count($eventsAttended) . ')');
    foreach ($eventsAttended as $eventid => $eventName) {
        $newArray['value'] = $newArray['value'] . '<br />' . CHtml::link($eventName, array('events/view/id/' . $eventid));
    }
    array_push($arrDetails['attributes'],$newArray);
	
	
    foreach ($customFields as $cf) {
        $value = "";
        foreach ($model->customfieldvalues as $cfv) {
            if ($cfv->custom_field_id == $cf->id) {
                $value = $cfv->value;
            }
        }
        $newArray = array('label' => "$cf->label", 'type'=>'text', 'value'=>"$value");
        array_push($arrDetails['attributes'],$newArray);
    }
    
    $this->widget('zii.widgets.CDetailView', $arrDetails);
?>
	<p>
	<?php
	echo CHtml::link('Edit', array('/pnm/update', 'id'=>$model->id));
	?>
	</p>
</div>
